<%@ taglib prefix="tiles" uri="http://tiles.apache.org/tags-tiles" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions"%>
<%@ taglib prefix="form" uri="http://www.springframework.org/tags/form" %>
<%@ taglib prefix="security" uri="http://www.springframework.org/security/tags" %>

<h1>User Detail</h1>

<div id="bookings">			
	<label for="name">name:</label>
	${user.nickname}<br/>
	 
	<label for="state">user name:</label>
	${user.username}<br/>
	
	<label for="zip">password:</label>
	${user.password}<br/>
</div>



<div id="bookings">
	<security:authorize ifAllGranted="ROLE_USER">		
	<c:if test="${pageContext.request.userPrincipal != null && pageContext.request.userPrincipal.name == user.username}">
		<a href="<c:url value="/users/profile" />">Manage user</a>
		<a href="<c:url value="/users/${user.id}/blogs/new" />">New Blog</a>
	</c:if>
	</security:authorize>
	<a href="<c:url value="/users/${user.id}/blogs" />">Blog List</a>
</div>
<div id="bookings">
	<c:if test="${!empty bookingList}">
	<h2>Current Hotel Bookings</h2>
	<table class="summary">
		<thead>
			<tr>
				<th>Name</th>
				<th>Address</th>
				<th>City, State</th>
				<th>Check in Date</th>
				<th>Check out Date</th>
				<th>Confirmation Number</th>
			</tr>
		</thead>
		<tbody>
			<c:forEach var="booking" items="${bookingList}">
			<tr>
				<td>${booking.hotel.name}</td>
				<td>${booking.hotel.address}</td>
				<td>${booking.hotel.city}, ${booking.hotel.state}</td>
				<td>${booking.checkinDate}</td>
				<td>${booking.checkoutDate}</td>
				<td>${booking.id}</td>
			</tr>
			</c:forEach>
		</tbody>
	</table>
	</c:if>
</div>
<div id="bookings">
	<c:if test="${!empty userFollowedBookingLost}">
	<h2>Followed Hotel Bookings</h2>
	<table class="summary">
		<thead>
			<tr>
				<th>Name</th>
				<th>Address</th>
				<th>City, State</th>
				<th>Check in Date</th>
				<th>Check out Date</th>
				<th>Confirmation Number</th>
			</tr>
		</thead>
		<tbody>
			<c:forEach var="booking" items="${userFollowedBookingLost}">
			<tr>
				<td>${booking.hotel.name}</td>
				<td>${booking.hotel.address}</td>
				<td>${booking.hotel.city}, ${booking.hotel.state}</td>
				<td>${booking.checkinDate}</td>
				<td>${booking.checkoutDate}</td>
				<td>${booking.id}</td>
			</tr>
			</c:forEach>
		</tbody>
	</table>
	</c:if>
</div>
<div id="hotelResults">
<c:if test="${not empty hotelList}">
	<table class="summary">
		<thead>
			<tr>
				<th>Name</th>
				<th>Address</th>
				<th>City, State</th>
				<th>Zip</th>
				<th>Action</th>
			</tr>
		</thead>
		<tbody>
			<c:forEach var="hotel" items="${hotelList}">
				<tr>
					<td>${hotel.name}</td>
					<td>${hotel.address}</td>
					<td>${hotel.city}, ${hotel.state}, ${hotel.country}</td>
					<td>${hotel.zip}</td>
					<td><a href="../hotels/${hotel.id}">View Hotel</a></td>
				</tr>
			</c:forEach>
		</tbody>
	</table>
</c:if>
</div>	